/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.jomijushi.fid.dominio;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

/**
 *
 * @author Administrador
 */
@Entity
@Table(name = "fid_sucursal", catalog = "fid", schema = "")
@NamedQueries({
    @NamedQuery(name = "FidSucursal.findAll", query = "SELECT f FROM FidSucursal f"),
    @NamedQuery(name = "FidSucursal.findByFidSucursalId", query = "SELECT f FROM FidSucursal f WHERE f.fidSucursalId = :fidSucursalId"),
    @NamedQuery(name = "FidSucursal.findByName", query = "SELECT f FROM FidSucursal f WHERE f.name = :name"),
    @NamedQuery(name = "FidSucursal.findByCreatedAt", query = "SELECT f FROM FidSucursal f WHERE f.createdAt = :createdAt"),
    @NamedQuery(name = "FidSucursal.findByUpdatedAt", query = "SELECT f FROM FidSucursal f WHERE f.updatedAt = :updatedAt"),
    @NamedQuery(name = "FidSucursal.findByCreatedby", query = "SELECT f FROM FidSucursal f WHERE f.createdby = :createdby"),
    @NamedQuery(name = "FidSucursal.findByUpdatedby", query = "SELECT f FROM FidSucursal f WHERE f.updatedby = :updatedby"),
    @NamedQuery(name = "FidSucursal.findBySucursalid", query = "SELECT f FROM FidSucursal f WHERE f.sucursalid = :sucursalid"),
    @NamedQuery(name = "FidSucursal.findByEstablecimientoid", query = "SELECT f FROM FidSucursal f WHERE f.establecimientoid = :establecimientoid")})
public class FidSucursal implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "fid_sucursal_id")
    private Integer fidSucursalId;
    @Column(name = "name")
    private String name;
    @Column(name = "created_at")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createdAt;
    @Column(name = "updated_at")
    @Temporal(TemporalType.TIMESTAMP)
    private Date updatedAt;
    @Column(name = "createdby")
    private Integer createdby;
    @Column(name = "updatedby")
    private Integer updatedby;
    @Column(name = "sucursalid")
    private Integer sucursalid;
    @Column(name = "establecimientoid")
    private Integer establecimientoid;
    @OneToMany(mappedBy = "fidSucursal")
    private List<FidEstablecimiento> fidEstablecimientoList;

    public FidSucursal() {
    }

    public FidSucursal(Integer fidSucursalId) {
        this.fidSucursalId = fidSucursalId;
    }

    public Integer getFidSucursalId() {
        return fidSucursalId;
    }

    public void setFidSucursalId(Integer fidSucursalId) {
        Integer oldFidSucursalId = this.fidSucursalId;
        this.fidSucursalId = fidSucursalId;
        changeSupport.firePropertyChange("fidSucursalId", oldFidSucursalId, fidSucursalId);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        String oldName = this.name;
        this.name = name;
        changeSupport.firePropertyChange("name", oldName, name);
    }

    public Date getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(Date createdAt) {
        Date oldCreatedAt = this.createdAt;
        this.createdAt = createdAt;
        changeSupport.firePropertyChange("createdAt", oldCreatedAt, createdAt);
    }

    public Date getUpdatedAt() {
        return updatedAt;
    }

    public void setUpdatedAt(Date updatedAt) {
        Date oldUpdatedAt = this.updatedAt;
        this.updatedAt = updatedAt;
        changeSupport.firePropertyChange("updatedAt", oldUpdatedAt, updatedAt);
    }

    public Integer getCreatedby() {
        return createdby;
    }

    public void setCreatedby(Integer createdby) {
        Integer oldCreatedby = this.createdby;
        this.createdby = createdby;
        changeSupport.firePropertyChange("createdby", oldCreatedby, createdby);
    }

    public Integer getUpdatedby() {
        return updatedby;
    }

    public void setUpdatedby(Integer updatedby) {
        Integer oldUpdatedby = this.updatedby;
        this.updatedby = updatedby;
        changeSupport.firePropertyChange("updatedby", oldUpdatedby, updatedby);
    }

    public Integer getSucursalid() {
        return sucursalid;
    }

    public void setSucursalid(Integer sucursalid) {
        Integer oldSucursalid = this.sucursalid;
        this.sucursalid = sucursalid;
        changeSupport.firePropertyChange("sucursalid", oldSucursalid, sucursalid);
    }

    public Integer getEstablecimientoid() {
        return establecimientoid;
    }

    public void setEstablecimientoid(Integer establecimientoid) {
        Integer oldEstablecimientoid = this.establecimientoid;
        this.establecimientoid = establecimientoid;
        changeSupport.firePropertyChange("establecimientoid", oldEstablecimientoid, establecimientoid);
    }

    public List<FidEstablecimiento> getFidEstablecimientoList() {
        return fidEstablecimientoList;
    }

    public void setFidEstablecimientoList(List<FidEstablecimiento> fidEstablecimientoList) {
        this.fidEstablecimientoList = fidEstablecimientoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (fidSucursalId != null ? fidSucursalId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof FidSucursal)) {
            return false;
        }
        FidSucursal other = (FidSucursal) object;
        if ((this.fidSucursalId == null && other.fidSucursalId != null) || (this.fidSucursalId != null && !this.fidSucursalId.equals(other.fidSucursalId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return this.name;
        //return "com.jomijushi.fid.dominio.FidSucursal[fidSucursalId=" + fidSucursalId + "]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

}
